#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    string x;
    unordered_map<int, int> m[6];
    vector<int>v[6];
    while(n--)
    {
        cin>>x;
        int y=0;
        for(int i=0;i<x.size();i++)
        {
            y+=x[i];
        }
        v[x.size()].push_back(y);
        if(x.size()==1)
        {
            m[1][x[0]]++;
        }
        if(x.size()==2)
        {
            m[2][x[0]+x[1]]++;
        }
        if(x.size()==3)
        {
            m[3][x[0]+x[1]+x[2]]++;
            m[1][x[0]+x[1]-x[2]]++;
            m[1][x[2]+x[1]-x[0]]++;
        }
        if(x.size()==4)
        {
            m[4][x[0]+x[1]+x[2]+x[3]]++;
            m[2][x[0]+x[1]+x[2]-x[3]]++;
            m[2][-x[0]+x[1]+x[2]+x[3]]++;
        }
        if(x.size()==5)
        {
            m[5][x[0]+x[1]+x[2]+x[3]+x[4]]++;
            m[3][x[0]+x[1]+x[2]+x[3]-x[4]]++;
            m[3][-x[0]+x[1]+x[2]+x[3]+x[4]]++;
            m[1][-x[0]-x[1]+x[2]+x[3]+x[4]]++;
            m[1][x[0]+x[1]+x[2]-x[3]-x[4]]++;
        }
    }
    int ans=0;
    for(int i=1;i<=5;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            ans+=m[i][v[i][j]];
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}